package Stirng类;

import java.util.Locale;
class Student{
    int age;
    String name;

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    public Student(int age, String name) {
        this.age = age;
        this.name = name;
    }
}
public class Test {
    public static void main(String[] args) {
        final char[]arr=new char[]{'a','b','c'};
        arr[1]='a';
    }
    public static void main7(String[] args) {
            char[] ch = new char[]{'a', 'b', 'c'};
            String s1 = new String(ch); // s1对象并不在常量池中
             s1.intern();
             // s1.intern()；调用之后，会将s1对象的引用放入到常量池中
            String s2 = "abc";
            // "abc" 在常量池中存在了，s2创建时直接用常量池中"abc"的引用
            System.out.println(s1 == s2);
    }
    public static void main6(String[] args) {
        String tmp="abcd";
        String tmp2="abcd";
        String tmp3=new String("abcd");
        String tmp4=new String("123");
        tmp4.intern();
    }
    public static void main5(String[] args) {
        Student student=new Student(18,"wzj");
        System.out.println(String.valueOf(student));

    }
    public static void main4(String[] args) {
        String tmp=new String(" ab cd ef ");
        System.out.println(tmp.trim());
    }
    public static void main3(String[] args) {
        String tmp=new String("hello world hello bit");
        String[]arr=tmp.split(" ",2);
        for (String tmp1:arr) {
            System.out.println(tmp1);
        }
        String str = "name=zhangsan&age=18" ;
        String[] result = str.split("&") ;
        for(String s: result) {
            //s[0]=  name=zhangsan
            //s[1]=  age=18
            String[] tmp1=s.split("=");
            for (String s1:tmp1) {
                System.out.println(s1);
            }

        }
    }
    public static void main2(String[] args) {
        String tmp=new String("abcabaa");
        String tmp1=tmp.replace('a','6');
        System.out.println(tmp1);
        System.out.println(tmp.replace("ab", "66"));
    }





    public static void main1(String[] args) {
        String tmp="abcdabcdacbd";
        String tmp1=new String("abcd");
        char[]arr=new char[]{'h','e','l','l','o'};
        String tmp2=new String(arr);
        for (int i = 0; i < tmp2.length(); i++) {
            char ch=tmp2.charAt(i);
            System.out.println(ch);
        }
        System.out.println(tmp2.indexOf('l',3));
        System.out.println(tmp.indexOf("cda",3));
        System.out.println(tmp.lastIndexOf("cda"));
        String tmp3=tmp.toUpperCase();
        System.out.println(tmp3.toLowerCase());
        int[] arr2=new int[]{1,2,3,4};
        String m=String.valueOf(arr2);
        String.valueOf(arr);
        String tmp4="22.5";
        double a=Double.parseDouble(tmp4);
        char[]arr5=tmp2.toCharArray();
        for (int i = 0; i < arr5.length; i++) {
            System.out.println(arr5[i]);
        }
    }
}
